/**
*	Time-Show
**/
/*
var Step = {
	dx : 0,
	dy : 0,
	dh : 0,
	dw : 0,
	tframes : 0,
	frames : 0,
	pause : 0,
	tpause : 0,
	filter : "",
	scode : ""
}
var Movement = {
	object : null,
	orx : "0px",
	ory : "0px",
	orh : "0px",
	orw : "0px",
	vi : true,
	steps : Array(),
	index : 0,
	enabled : false
}
*/
function us(x){//Cheap Math.abs()
return (x>0)?x:-x;
}
var TimeShow = {
	curscene : 0,
	scenes : Array(),
	movements : Array(),
	started : false,
	ticktack : setInterval("if(TimeShow.started)TimeShow.doeval();",1),
	clearpx : function (stro){
		str=""+stro+"";
		return (str.replace("px","").replace("pt",""))*1;
	},
	RPos : function (Cobject){
		try{
			if (!Cobject.oid){
				Cobject.oid=TimeShow.movements.push({	object : Cobject,	steps : Array(),	index : 0,	orx : Cobject.style.left,	ory : Cobject.style.top,	orh : Cobject.style.height,	orw : Cobject.style.width,	vi : true,	enabled : false});
			}else{
				TimeShow.movements[Cobject.oid-1].orx=Cobject.style.left;
				TimeShow.movements[Cobject.oid-1].ory=Cobject.style.top;
				TimeShow.movements[Cobject.oid-1].orh=Cobject.style.height;
				TimeShow.movements[Cobject.oid-1].orw=Cobject.style.width;
				TimeShow.movements[Cobject.oid-1].vi=(Cobject.style.visibility!="hidden");
			}
		}catch(e){errors.record(e,"TimeShow.RPos->func()");}
	},
	loadScene : function (scene){
	},
	nextScene : function (){
	},
	prevScene : function (){
	},
	firstScene : function (){
	},
	lastScene : function (){
	},
	gotoPoint : function (object,dx,dy,fl){
		try{
			var lx = this.clearpx(object.style.left);
			var ly = this.clearpx(object.style.top);
			var vx = (dx-lx)/fl;
			var vy = (dy-ly)/fl;
			try{
				if (dx!==false)
					object.style.left = Math.floor(lx+vx)+"px";
				if (dy!==false)
					object.style.top = Math.floor(ly+vy)+"px";
			}catch(e){errors.record(e,"TimeShow.gotoPoint->move");}
		}catch(e){errors.record(e,"TimeShow.gotoPoint->func()");}
	},
	grow : function (object,dh,dw,fl){
		try{
			var lh = this.clearpx(object.style.height);
			var lw = this.clearpx(object.style.width);
			var vh = (dh-lh)/fl;
			var vw = (dw-lw)/fl;
			try{
				if (dh!==false)
					object.style.height = parseInt(lh+vh)+"px";
				if (dw!==false)
					object.style.width = parseInt(lw+vw)+"px";
			}catch(e){errors.record(e,"TimeShow.grow->grow");}
		}catch(e){errors.record(e,"TimeShow.grow->func()");}
	},
	doeval : function (){
		for (var i=0;i<this.movements.length;i++){
			if (this.movements[i].enabled){
				try{
					if (this.movements[i].steps[this.movements[i].index].scode){
						try{
							eval(this.movements[i].steps[this.movements[i].index].scode);
						}catch(e){}
					}
				}catch(e){errors.record(e,"TimeShow.doeval->execute code");}
				if (this.movements[i].steps[this.movements[i].index].pause>1){
					try {
						if (this.movements[i].steps[this.movements[i].index].filter &&
							this.movements[i].steps[this.movements[i].index].pause == this.movements[i].steps[this.movements[i].index].tpause
							){
							this.movements[i].object.style.filter=this.movements[i].steps[this.movements[i].index].filter;
							this.movements[i].object.filters.revealtrans.Apply();
							this.movements[i].object.style.visibility="visible";
							this.movements[i].object.filters.revealtrans.Play();
						}
					}catch(e){errors.record(e,"TimeShow.doeval->use filter");}
					this.movements[i].steps[this.movements[i].index].pause--;
				}else if (this.movements[i].steps[this.movements[i].index].pause==1){
					this.movements[i].steps[this.movements[i].index].pause=this.movements[i].steps[this.movements[i].index].tpause;
					this.movements[i].index++;
					try{this.movements[i].object.filters.revealtrans.Stop();this.movements[i].object.style.filter="";}catch(e){}
				} else
				if (this.movements[i].steps[this.movements[i].index].frames<0){
					this.movements[i].index++;
					if (this.movements[i].index>=this.movements[i].steps.length){
						this.movements[i].enabled=false;
					}
					try{
						var obj=this.movements[i];
							this.gotoPoint(obj.object,obj.steps[obj.index].dx,obj.steps[obj.index].dy,obj.steps[obj.index].frames);
							this.grow(obj.object,obj.steps[obj.index].dh,obj.steps[obj.index].dw,obj.steps[obj.index].frames);
							if (obj.steps[obj.index].frames!==false){
								obj.steps[obj.index].frames--;
							}
					}catch(e){errors.record(e,"TimeShow.doeval->action");}
				}else{
					try{
						var obj=this.movements[i];
							this.gotoPoint(obj.object,obj.steps[obj.index].dx,obj.steps[obj.index].dy,obj.steps[obj.index].frames);
							this.grow(obj.object,obj.steps[obj.index].dh,obj.steps[obj.index].dw,obj.steps[obj.index].frames);
							if (obj.steps[obj.index].frames!==false){
								obj.steps[obj.index].frames--;
							}
					}catch(e){errors.record(e,"TimeShow.doeval->action");}
				}
			}
		}
	},
	addMove : function (Cobject,Cdx,Cdy,Cdh,Cdw,Cframes,SC){
		if (!Cobject.oid){
			Cobject.oid=this.movements.push({	object : Cobject,	steps : Array(),	index : 0,	orx : Cobject.style.left,	ory : Cobject.style.top,	orh : Cobject.style.height,	orw : Cobject.style.width,	vi : true,	enabled : true});
		}
		if (Cframes==false){
			var pasmx=this.movements[Cobject.oid-1].orx;
			var pasmy=this.movements[Cobject.oid-1].ory;
			if (this.movements[Cobject.oid-1].steps.length){
				pasmx=this.movements[Cobject.oid-1].steps[this.movements[Cobject.oid-1].steps.length-1].dx;
				pasmy=this.movements[Cobject.oid-1].steps[this.movements[Cobject.oid-1].steps.length-1].dy;
			}
			var mx=(this.clearpx(pasmx)-Cdx);
			var my=(this.clearpx(pasmy)-Cdy);
			Cframes = parseInt(Math.sqrt(Math.pow(mx,2)+Math.pow(my,2))/8);
		}
		if (Cdx && Cdy){
			Cdx -= this.clearpx(Cobject.style.width)/2;
			Cdy -= this.clearpx(Cobject.style.height)/2;
		}
		this.movements[Cobject.oid-1].steps.push({	dx : Cdx,	dy : Cdy,	dh : Cdh,	dw : Cdw,	frames : Cframes,	tframes : Cframes, pause : 0, tpause : 0, filter : false, scode : SC});
		this.movements[Cobject.oid-1].enabled=true;
	},
	addPause : function (Cobject,Plength,SC){
		if (!Cobject.oid){
			Cobject.oid=this.movements.push({	object : Cobject,	steps : Array(),	index : 0,	orx : Cobject.style.left,	ory : Cobject.style.top,	orh : Cobject.style.height,	orw : Cobject.style.width,	vi : true,	enabled : true});
		}
		this.movements[Cobject.oid-1].steps.push({	dx : false,	dy : false,	dh : false,	dw : false,	frames : 0, tframes : 0, pause : Plength , tpause : Plength, filter : false, scode : SC});
		this.movements[Cobject.oid-1].enabled=true;
	},
	addFilter : function (Cobject,filter,dur){
		if (!Cobject.oid){
			Cobject.oid=this.movements.push({	object : Cobject,	steps : Array(),	index : 0,	orx : Cobject.style.left,	ory : Cobject.style.top,	orh : Cobject.style.height,	orw : Cobject.style.width,	vi : true,	enabled : true});
		}
		var MFIL = "revealtrans(Duration="+dur+",Transition="+filter+")";
		dur = parseInt(dur)*1000;
		var oxs=({	dx : false,	dy : false,	dh : false,	dw : false,	frames : 0, tframes : 0, pause : dur , tpause : dur , filter : MFIL, scode : ''});
		this.movements[Cobject.oid-1].steps = Array.concat(Array(oxs),this.movements[Cobject.oid-1].steps);
		this.movements[Cobject.oid-1].enabled=true;
	}
}
